source ~/.local/bin/ubuild.sh
cd $SCRIPT_FOLDER

nginx_port=`cat nginx.port`
dev_port=`cat dev.port`
log_file=log/`date +'%F-%T'`.log

swagger(){
  link=("swagger.yaml" "swagger.json")
  for i in ${link[@]};do
    curl http://localhost:$dev_port/$i |tee log/$i
  done
  link=("swagger" "redoc")
  for i in ${link[@]};do
    open_url http://localhost:$dev_port/$i
  done
}

register(){
  curl http://localhost:$nginx_port/o/applications/register/ \
    | tee $log_file
}
comments(){
    <<EOF
    -H "Content-Type: application/json"
EOF
  curl -v \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -XPOST \
    --data "chirping=1599804463146&offset=0&limit=10" \
    http://localhost:$dev_port/chirping/comments | tee log/$RANDOM
}

fetch(){
  curl -v http://localhost:$dev_port/chirping/fetch | tee log/$RANDOM
}

pref(){
  curl -v http://localhost:$dev_port/pref/query | tee log/$RANDOM
}

dev_index(){
  url=http://localhost:$dev_port
  open_url $url
}
$@
cd $CD
